Made all basic crud functions work and refactoring