Improved isOption function