Cleaned up code
Added bash function