updated with some fixes