added iphone version and cleaned up code a little