Added valid expression check