remove shitty sql code from controller