diff --git a/entityreference_prepopulate.module b/entityreference_prepopulate.module
index 8a67fa0..86f4fd5 100644
--- a/entityreference_prepopulate.module
+++ b/entityreference_prepopulate.module
@@ -330,7 +330,7 @@ function entityreference_prepopulate_get_values($field, $instance, $validate = T
  */
 function entityreference_prepopulate_get_values_from_cache($field, $instance) {
   // Try to get the form out of cache.
-  if (!$form_build_id = isset($_GET['form_build_id']) ? $_GET['form_build_id'] : isset($_POST['form_build_id']) ? $_POST['form_build_id'] : NULL) {
+  if (!$form_build_id = (isset($_GET['form_build_id']) ? $_GET['form_build_id'] : isset($_POST['form_build_id'])) ? $_POST['form_build_id'] : NULL) {
     return;
   }
