Edited code to attempt to prevent Java/Javascript conversion errors.