Tested version with direction feature and fix some bugs