Completely changed to make things much more simpler