added loop and other features