Made captioning function
Cleaned up and merged