Changed select and update pattern
Code cleanup