Logout function added, Fixed Preview Bug