moved some functions to where clause and put boundedInsert into a seperate module