Initial Code (fixed small bugs)