Now uses prepared statement for offset variable