Fixed a few bugs
added better esl function