Moves sql WHERE building to a separate file