Refactoed to remove unneeded code