wrap chosen calls in if to stop js error