updated to share more code and for a little readability