updated with minor improvements