finally added Math.tan calculation correctly