Move function to where it is actually used
Remove unneeded db load
Remove some unnecessary checks & redundancies