Improved eval function