removed clusterfuck and implemented properly