Added new function

Added new function, made several small changes