Added version and error checking
modified alpha func