Removed redundant closing tags
fixed small bugs
reformated code