Moved query execution into explicit execute() function