amek it working
corrected a few bug due to merging and code updating