updated to work with mecode