Added modal functions - working but could be better