Added error handling
Added exponentiation