fixed bug in sml part of code